<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
    <title>美策平台</title>
    <link rel="icon" type="image/png" href="/img/icon.png">
    <link rel="stylesheet" type="text/css" href="../../datepicker/jquery-ui.min.css">
    <link rel="stylesheet" type="text/css" href="../../css/app.css">
    <link rel="stylesheet" type="text/css" href="../../css/index.css">
    <script type="text/javascript" src="../../js/jquery.min.js"></script>
    <script type="text/javascript" src="/pc/js/all.js"></script>
</head>
<body>
<!--
    制作者：九哥
    页面：岗位列表
    时间：2019-03-01
-->





<!----------岗位页面---------->
<div id="jobPage"><!--此ID页面切换用-->
    <div id="jobTitle">
        <b>发布的岗位</b>
        <img src="../../images/return.png" id="jobRtn"
             onclick="history.go(-1);">
    </div>
    <div id="jobDetail">
        <table class="toJobShow" id="inload">
            <tr>
                <td style="text-align:center;" colspan="2">
                    加载中...
                </td>
            </tr>
        </table>
    </div>
    <div class="btn">
        <input type="hidden" id="page" value="1">
        <button onclick="getMoreList()">点击显示更多</button>
    </div>
</div>
<!----------岗位页面---------->





<!----------错误提示---------->
<div id="errMsg"></div>
<!----------错误提示---------->
</body>

<script type="text/javascript" src="../../js/cache.js"></script>
<script type="text/javascript" src="../../js/app.js"></script>
</html>

<script type="text/javascript">
    (function(){
        getIndexList();
    })();
    //岗位列表
    function getIndexList(){
        var userInfo = cacheGet('userInfo');
        var page = $('#page').val();
        var formData = {
            app_access:app_access,
            token:userInfo.token,
            page:page
        };
        $.ajax({
            type:'post',
            url:getDomain()+'/job-get',
            data:formData,
            success: function (res) {
                //console.log(res); return
                $('#inload').hide();
                var h = '';
                if (res.code!=0) {
                    h += '<table class="toJobShow">';
                    h += '<tr>';
                    h += '<td colspan="2" style="text-align:center;">没有信息</td>';
                    h += '</tr>';
                    h += '</table>';
                    $('#jobDetail').html(h);
                    $('.btn').hide();
                    getAppErrMsg(res.msg,'',0); return
                }
                console.log(res.data);
                var resData = res.data;
                for (var i in resData) {
                    h += '<table class="toJobShow" onclick="getJobShow('+resData[i].id+')">';
                    h += '<tr>';
                    h += '<td width="60">';
                    if (resData[i].head!='') {
                        h += '<img src="'+resData[i].head+'" width="40">';
                    } else {
                        h += '<img src="../../images/toux01.png" width="40">';
                    }
                    h += '</td>';
                    h += '<td>'+resData[i].cname+'</td>';
                    h += '</tr>';
                    h += '<tr>';
                    h += '<td>联系人</td>';
                    h += '<td class="right">'+resData[i].contact+'</td>';
                    h += '</tr>';
                    h += '<tr>';
                    h += '<td>招聘工种</td>';
                    h += '<td class="right">'+resData[i].jobName+'</td>';
                    h += '</tr>';
                    h += '<tr>';
                    h += '<td>所在地</td>';
                    h += '<td class="right">'+resData[i].address+'</td>';
                    h += '</tr>';
                    h += '</table>';
                }
                $('#jobDetail').html(h);
                $('#page')[0].value = page * 1 + 1;
            }
        });
    }
    //岗位列表
    function getMoreList(){
        var userInfo = cacheGet('userInfo');
        var page = $('#page').val();
        var formData = {
            app_access:app_access,
            token:userInfo.token,
            page:page
        };
        $.ajax({
            type:'post',
            url:getDomain()+'/job-get',
            data:formData,
            success: function (res) {
                //console.log(res); return
                if (res.code!=0) {
                    getAppErrMsg('没有更多！','',0); return
                }
                console.log(res.data);
                var resData = res.data;
                var h = '';
                for (var i in resData) {
                    h += '<table class="toJobShow" onclick="getJobShow('+resData[i].id+')">';
                    h += '<tr>';
                    h += '<td width="60">';
                    if (resData[i].head!='') {
                        h += '<img src="'+resData[i].head+'" width="40">';
                    } else {
                        h += '<img src="../../images/toux01.png" width="40">';
                    }
                    h += '</td>';
                    h += '<td>'+resData[i].cname+'</td>';
                    h += '</tr>';
                    h += '<tr>';
                    h += '<td>联系人</td>';
                    h += '<td class="right">'+resData[i].contact+'</td>';
                    h += '</tr>';
                    h += '<tr>';
                    h += '<td>招聘工种</td>';
                    h += '<td class="right">'+resData[i].jobName+'</td>';
                    h += '</tr>';
                    h += '<tr>';
                    h += '<td>所在地</td>';
                    h += '<td class="right">'+resData[i].address+'</td>';
                    h += '</tr>';
                    h += '</table>';
                }
                $('#jobDetail').append(h);
                $('#page')[0].value = page * 1 + 1;
            }
        });
    }
//    //岗位详情
     function getJobShow(id){
         // window.location.href = 'jobShow.html?jobId='+id;
           window.location.href = '/h5/index/job/jobShow.html?jobId='+id;
     }
    //请求地址
    function getDomain(){
        return '/api/my/pub';
    }
</script>